<extend name="Public:base"/>

<block name="content">

    <div class="feeldesk-form pd0">

		<form action="" class="layui-form" method="post" enctype="multipart/form-data">

		<div class="layui-tab">

            <ul class="layui-tab-title">

                <li class="layui-this">{:L('TRANSFORM')}</li>

				<div class="form-submit">

					<a href="javascript:" class="layui-btn layui-btn-normal submitForm">{:l('SUBMIT')}</a>

					<a href="javascript:history.go(-1);" class="layui-btn layui-btn-normal titleCancel">{:l('CANCEL')}</a>

					<div class="clear"></div>

				</div>

            </ul>

        </div>

        <div class="form-content form-content-transform">

            <div class="form-nav pb25" style="padding-left: 5%;">

                <ul class="border-none">

                    <li ><a href="javascript:" class="form-tab active">{:L('TRANSFORM_TYPE')}</a></li>

                </ul>

            </div>

            <div class="form-item wd50">

                <div class="layui-form-item">

                    <label class="layui-form-label"></label>

                    <div class="layui-input-inline">

                        <input type="radio" name="transform[type]" value="1" lay-filter="transform_type" title="{:L('NEW_CUSTOMER')}" checked>

                        <input type="radio" name="transform[type]" value="2" lay-filter="transform_type" title="{:L('ASSOCIATE_CUSTOMER')}">

                    </div>

                </div>

                <div class="layui-form-item hidden" id="transformCustomerId">

                    <label class="layui-form-label"></label>

                    <div class="layui-input-inline">

                        <input type="radio" id="selectCustomerInput" class="layui-input" name="transform[customer_id]" title="{:L('NO_CUSTOMER_SELECTED')}" checked value="" readonly />

                        <div id="selectCustomer" class="feelcrm-commbtn" >{:L('SELECT_CUSTOMER')}</div>

                    </div>

                </div>

                <div class="layui-form-item hidden" id="transformUpdate">

                    <label class="layui-form-label"></label>

                    <div class="layui-input-inline">

                        <input type="radio" name="transform[update]" value="1" title="{:L('UPDATE_INCOMPLETE_INFORMATION')}" checked>

                        <input type="radio" name="transform[update]" value="2" title="{:L('UPDATE_EXISTING_INFORMATION')}" >

                    </div>

                </div>

                <div class="layui-form-item">

                    <label class="layui-form-label"></label>

                    <div class="layui-input-inline">

                        <input type="radio" name="transform[sync_follow]" value="1" title="{:L('SYNCHRONIZE_CONTACT_RECORDS')}" checked>

                        <input type="radio" name="transform[sync_follow]" value="2" title="{:L('OUT_OF_SYNC')}">

                    </div>

                </div>

                <div class="layui-form-item" >

                    <label class="layui-form-label"></label>

                    <div class="layui-input-inline">

                        <input type="radio" name="transform[create_contacter]" lay-filter="transform_contacter" value="1" title="{:L('CREATE_CONTACTER')}" checked>

                        <input type="radio" name="transform[create_contacter]" lay-filter="transform_contacter" value="2" title="{:L('NOT_CREATE')}">

                    </div>

                </div>

            </div>

        </div>

		<php>
			$t = 0;
			$ft = 0;
			$reg = 0;
		</php>
        <div class="form-content form-content1 wd50 fl">

            <div class="form-nav pb25 pt0" style="padding-left: 10%;">

                <ul class="border-none">

                    <li ><a href="javascript:" class="form-tab active">{:L('CUSTOMER_INFO')}</a></li>

                </ul>

            </div>

            <div class="form-item pb25 pt20">

               <volist name="customerform" id="vo">

                    <div class="layui-form-item">

                        <label class="layui-form-label">

                            <eq name="vo.is_required" value="0"><span class="red">*</span> </eq>

                            {$vo.form_description}

                        </label>

                        <eq name="vo.form_type" value="region">

                            <php>
                                $reg++;
                            </php>


                            {:W('Region/getRegionEdit',['customer_form',$vo['form_name'],$reg,$customerData])}

                        <else/>

                        <div class="layui-input-inline">

                            <eq name="vo.form_type" value="text">

                                <!-- 单行文本框 -->
                                <input type="text" name="customer_form[{$vo.form_name}]" value="{$customerData[$vo['form_name']]}" placeholder="" class="layui-input">

                            </eq>

                             <eq name="vo.form_type" value="phone">

                                <!-- {:L('CELL_PHONE')} -->
                                <input type="text" onKeyPress="if (event.keyCode!=46 && event.keyCode!=45 && event.keyCode<48 || event.keyCode>57) event.returnValue=false" name="customer_form[{$vo.form_name}]" value="{$customerData[$vo['form_name']]}" placeholder="" class="layui-input">

                            </eq>

                             <eq name="vo.form_type" value="email">

                                <!-- {:L('MAILBOX')} -->
                                <input type="text" name="customer_form[{$vo.form_name}]" value="{$customerData[$vo['form_name']]}" placeholder="" class="layui-input">

                            </eq>

                             <eq name="vo.form_type" value="number">

                                <!-- {:L('DIGITAL')} -->
                                <input type="number" onKeyPress="if (event.keyCode!=46 && event.keyCode!=45 && event.keyCode<48 || event.keyCode>57) event.returnValue=false" name="customer_form[{$vo.form_name}]" value="{$customerData[$vo['form_name']]}" placeholder="" class="layui-input">

                            </eq>

                            <eq name="vo.form_type" value="decimal">

                                <!-- 小数 -->
                                <input type="text" name="customer_form[{$vo.form_name}]" placeholder="" class="layui-input">

                            </eq>

                            <eq name="vo.form_type" value="select">

                                <!-- 下拉菜单 -->
                                <select name="customer_form[{$vo.form_name}]">

                                    <option value="">{$vo.form_description}</option>

                                    <foreach name="vo.option" item="op">

                                        <option value="{$op}" <eq name="customerData[$vo[form_name]]" value="$op" >selected</eq>>{$op}</option>

                                    </foreach>

                                </select>

                            </eq>

                            <eq name="vo.form_type" value="select_text">

                                <php>
                                    $st++;
                                </php>
                                <!-- 下拉填写 -->
                                {:W('Update/selectTextForm',['customer',$vo,$st])}

                            </eq>

                            <!-- 时间控件 -->
                            <eq name="vo.form_type" value="date">

                                <php>
                                    $ft++;
                                </php>

                                <input type='text' name="customer_form[{$vo.form_name}]" class="layui-input cursor layui-form-time" id="form_time<php>echo $ft;</php>" placeholder="{:L('SELECT_TIME')}" >

                            </eq>


                            <eq name="vo.form_type" value="checkbox">

                                <!-- 复选框 -->
                                <volist name="vo.option" id="op">

                                    <input type="checkbox" name="customer_form[{$vo.form_name}][]" <in name="op" value="$customerData[$vo[form_name]]">checked</in> lay-skin="primary" title="{$op}" value="{$op}">

                                </volist>

                            </eq>

                            <eq name="vo.form_type" value="radio">

                                <!-- 单选框-->
                                <volist name="vo.option" id="op">

                                    <input type="radio" name="customer_form[{$vo.form_name}]" <eq name="customerData[$vo[form_name]]" value="$op" >checked</eq> value="{$op}" title="{$op}">

                                </volist>

                            </eq>

                            <!-- 文本域 -->
                            <eq name="vo.form_type" value="textarea">

                                <php>
                                    $t++
                                </php>

                                <textarea class="layui-textarea layui-hide ticket-textarea" name="customer_form[{$vo.form_name}]" id="ticketEditor<php>echo $t;</php>">{$customerData[$vo['form_name']]}</textarea>

                            </eq>

                        </div>

                        </eq>

                        <notempty name="vo.form_explain">

                            <i class="layui-icon layui-icon-about intro-icon" data-note="{$vo.form_explain}"></i>

                        </notempty>

                    </div>

                </volist>

            </div>

        </div>

		<div class="form-content form-content2 wd50 fl ">

            <div class="form-nav pb25 pt0" style="padding-left: 10%;">

                <ul class="border-none">

                    <li><a href="javascript:" class="form-tab active">{:L('CUSTOMER_CONTACT')}</a></li>

                </ul>

            </div>

			<div class="form-item pb25 pt20 create-both-end">

                <volist name="contacterform" id="vo">

                    <div class="layui-form-item">

                        <label class="layui-form-label">

                            <eq name="vo.is_required" value="0"><span class="red">*</span> </eq>

                            {$vo.form_description}

                        </label>

                        <eq name="vo.form_type" value="region">

                            <php>
                                $reg++;
                            </php>

                            {:W('Region/getRegion',['contacter_form',$vo['form_name'],$reg])}

                        <else/>

                        <div class="layui-input-inline">

                            <eq name="vo.form_type" value="text">
                                <!-- 单行文本框 -->
                                <eq name="vo.form_name" value="wechat">

                                    <notempty name="wechat">

                                        <input type="text" name="contacter_form[{$vo.form_name}]" value="{$wechat}" readonly placeholder="" class="layui-input">

                                    <else/>

                                        <input type="text" name="contacter_form[{$vo.form_name}]" value="{$contacterData[$vo['form_name']]}" placeholder="" class="layui-input">

                                    </notempty>

                                <else/>

                                    <input type="text" name="contacter_form[{$vo.form_name}]" value="{$contacterData[$vo['form_name']]}" placeholder="" class="layui-input">

                                </eq>

                            </eq>

                             <eq name="vo.form_type" value="phone">

                                <!-- {:L('CELL_PHONE')} -->
                                <input type="text" onKeyPress="if (event.keyCode!=46 && event.keyCode!=45 && event.keyCode<48 || event.keyCode>57) event.returnValue=false" name="contacter_form[{$vo.form_name}]" value="{$contacterData[$vo['form_name']]}" placeholder="" class="layui-input">

                            </eq>

                             <eq name="vo.form_type" value="email">

                                <!-- {:L('MAILBOX')} -->
                                <input type="text" name="contacter_form[{$vo.form_name}]" value="{$contacterData[$vo['form_name']]}" placeholder="" class="layui-input">

                            </eq>

                             <eq name="vo.form_type" value="number">

                                <!-- {:L('DIGITAL')} -->
                                <input type="number" onKeyPress="if (event.keyCode!=46 && event.keyCode!=45 && event.keyCode<48 || event.keyCode>57) event.returnValue=false" name="contacter_form[{$vo.form_name}]" value="{$contacterData[$vo['form_name']]}" placeholder="" class="layui-input">

                            </eq>

                            <eq name="vo.form_type" value="decimal">

                                <!-- 小数 -->
                                <input type="text" name="contacter_form[{$vo.form_name}]" placeholder="" class="layui-input">

                            </eq>

                            <eq name="vo.form_type" value="select">

                                <!-- 下拉菜单 -->
                                <select name="contacter_form[{$vo.form_name}]">

                                    <option value="">{$vo.form_description}</option>

                                    <foreach name="vo.option" item="op">

                                        <option value="{$op}" <eq name="contacterData[$vo[form_name]]" value="$op" >selected</eq>>{$op}</option>

                                    </foreach>

                                </select>

                            </eq>

                            <eq name="vo.form_type" value="select_text">

                                <php>
                                    $st++;
                                </php>
                                <!-- 下拉填写 -->
                                {:W('Update/selectTextForm',['contacter',$vo,$st])}

                            </eq>

                            <!-- 时间控件 -->
                            <eq name="vo.form_type" value="date">

                                <php>
                                    $ft++;
                                </php>

                                <input type='text' name="contacter_form[{$vo.form_name}]" class="layui-input cursor layui-form-time" id="form_time<php>echo $ft;</php>" placeholder="{:L('SELECT_TIME')}" >

                            </eq>

                            <eq name="vo.form_type" value="checkbox">

                                <!-- 复选框 -->
                                <volist name="vo.option" id="op">

                                    <input type="checkbox" name="contacter_form[{$vo.form_name}][]" lay-skin="primary" title="{$op}" value="{$op}">

                                </volist>

                            </eq>

                            <eq name="vo.form_type" value="radio">

                                <!-- 单选框-->
                                <volist name="vo.option" id="op">

                                    <input type="radio" name="contacter_form[{$vo.form_name}]" value="{$op}" title="{$op}">

                                </volist>

                            </eq>

                            <!-- 文本域 -->
                            <eq name="vo.form_type" value="textarea">

                                <php>
                                    $t++
                                </php>

                                <textarea class="layui-textarea layui-hide ticket-textarea" name="contacter_form[{$vo.form_name}]" id="ticketEditor<php>echo $t;</php>"></textarea>

                            </eq>

                        </div>

                        </eq>

                        <notempty name="vo.form_explain">

                            <i class="layui-icon layui-icon-about intro-icon" data-note="{$vo.form_explain}"></i>

                        </notempty>

                    </div>

                </volist>

            </div>

		</div>

		<div class="clear"></div>

		</form>

    </div>

    <include file="Public:selectCustomer" />

    <include file="Public:language" />



    <script type="text/javascript">

        layui.use('form',function()
        {
            var form = layui.form;

            form.on('radio(transform_type)', function(data)
            {
                var type = data.value;

                if(type == 2)
                {
                    $('#transformCustomerId').slideDown(500);
                    $('#transformUpdate').slideDown(500);
                    $('.form-content1').hide();
                    $('.form-content2').removeClass('wd50').addClass('wd100').find('.form-nav').css('padding-left','5%');
                }
                else
                {
                    $('#transformCustomerId').slideUp(500);
                    $('#transformUpdate').slideUp(500);
                    $('.form-content1').show();
                    $('.form-content2').removeClass('wd100').addClass('wd50').find('.form-nav').css('padding-left','10%');
                }
            });

            form.on('radio(transform_contacter)',function (data)
            {
                var iscreate = data.value;

                if(iscreate == 2)
                {
                    $('.form-content1').removeClass('wd50').addClass('wd100').find('.form-nav').css('padding-left','5%');
                    $('.form-content2').hide();
                }
                else
                {
                    $('.form-content1').removeClass('wd100').addClass('wd50').find('.form-nav').css('padding-left','10%');
                    $('.form-content2').show();
                }
            })
        })

    </script>

</block>
